package com.flea.model.shoppigcart;

import com.flea.model.Product;

import java.time.Instant;
import java.util.ArrayList;
import java.util.List;

public class ShoppingCart {
    private List<ShoppingCartItem> shoppingCartItemList = new ArrayList<>();

    /**
     * Add one product to shopping cart
     *
     * @param product
     */
    public void addItem(Product product) {
        addItem(product, 1);
    }

    public void addItem(Product product, int quantity) {
        ShoppingCartItem shoppingCartItem = ShoppingCartItem.builder().product(product).quantity(quantity).addTime(Instant.now()).build();
        shoppingCartItemList.add(shoppingCartItem);
    }

    public List<ShoppingCartItem> getShoppingCartItemList() {
        return shoppingCartItemList;
    }
}
